package com.etone.smartAudit.controller;

import com.etone.smartAudit.dto.dictionary.DictionaryDTO;
import com.etone.smartAudit.service.DictionaryService;
import com.etone.smartAudit.vo.dictionary.DictionaryVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: sovy
 * @date: 2020/8/6
 * @description:
 */
@RestController
@AllArgsConstructor
@Api(tags = "字典配置", value = "DictionaryController")
public class DictionaryController {

    private DictionaryService dictionaryService;

    @ApiOperation(value = "获取字典内容《完》")
    @GetMapping("/dictionaries/{codes}")
    public List<DictionaryVO> list(
            @ApiParam(value = "键", required = true) @PathVariable List<String> codes
    ) {
        return dictionaryService.findByCode(codes);
    }

    @ApiOperation(value = "修改字典内容《完》")
    @PutMapping("/dictionaries")
    public void update(
            @ApiParam(value = "内容") @RequestBody @Validated List<DictionaryDTO> dictionaryDTOS
    ) {
        dictionaryService.update(dictionaryDTOS);
    }
}
